package mudfox.entity;

import com.alibaba.fastjson.JSON;
import org.bson.Document;
import mudfox.support.CommonUtil;

public class User {
    private String uid;
    private String name;
    private Integer age;
    private String address;

    public User() {
    }

    public User(String name, Integer age, String address) {
        this.uid = CommonUtil.getUid();
        this.name = name;
        this.age = age;
        this.address = address;
    }

    public String getUid() {
        return uid;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    @Override
    public String toString() {
        return JSON.toJSONString(this);
    }

    public Document toDocument() {
        Document doc = new Document();
        doc.put("uid", uid);
        doc.put("name", name);
        doc.put("age", age);
        doc.put("address", address);
        return doc;
    }

    public static User parseJson(String json) {
        return JSON.parseObject(json, User.class);
    }
}
